//
//  MessageModel.m
//  FPTest
//
//  Created by zhaohong on 2017/11/23.
//  Copyright © 2017年 zhaohong. All rights reserved.
//

#import "MessageModel.h"

@implementation MessageModel

- (void)setAttributes:(NSDictionary*)dataDic
{
    [super setAttributes:dataDic];
    
    //提取address字典，并转换为model对象，address的地址指向数据model
    NSDictionary *addressDic = [dataDic objectForKey:@"address"];
    MessageAddressModel *addressModel = [[MessageAddressModel alloc]initWithDataDic:addressDic];
    self.address = addressModel;
    
    
    //此处原理同上
    self.links = [[NSMutableArray alloc]init];
    NSArray *links = dataDic[@"links"];
    if (links == nil || links.count == 0) {
        return;
    }
    
    for (NSDictionary *infoDic in links) {
        MessageLinkModel *model = [[MessageLinkModel alloc]initWithDataDic:infoDic];
        [self.links addObject:model];
    }
    
}

@end
